package com.diligent.cloud.sfc.resources;

import com.canny.commons.model.ListResult;
import com.canny.commons.model.ObjectResult;
import com.canny.commons.model.Result;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;

/**
 * ProdBatchResource interface
 *
 * @author xf107278
 * @date 4/2/2020
 */
@RequestMapping("/sfc")
public interface ProdBatchResource {

    @PostMapping("/prod-batch-invalid")
    @ApiOperation(value = "车间现场/生产批作废", notes = "车间现场/生产批作废", tags = "车间现场")
    ResponseEntity<Result> updateBatchStatus(@ApiParam(name = "prodBatch", value = "批次号", type = "String") @RequestParam("prodBatch") String prodBatch, @ApiParam(name = "mdId", value = "模具id", type = "Long") @RequestParam("mdId") Long mdId,
                                             @ApiParam(name = "systemId", value = "账套Id", type = "String") @RequestParam("systemId") Long systemId,
                                             @ApiParam(name = "orderId", value = "工单Id", type = "Long") @RequestParam("orderId") Long orderId,
                                             @AuthenticationPrincipal Principal principal);

    @GetMapping("/prod-batch/{machCode}/{systemId}")
    @ApiOperation(value = "车间现场/已经开始了但是未结束的批", notes = "车间现场/已经开始了但是未结束的批", tags = "车间现场")
    ResponseEntity<ObjectResult> getBatch(@ApiParam(name = "machCode", value = "机台代码", type = "String") @PathVariable("machCode") String machCode,
                                          @ApiParam(name = "systemId", value = "账套Id", type = "String") @PathVariable("systemId") Long systemId, @AuthenticationPrincipal Principal principal);

    @GetMapping("/prod-batch-last/{machCode}/{systemId}")
    @ApiOperation(value = "车间现场/获取最后一个生产批", notes = "车间现场/获取最后一个生产批", tags = "车间现场")
    ResponseEntity<ObjectResult> getLastOneBatch(@ApiParam(name = "machCode", value = "机台代码", type = "String") @PathVariable("machCode") String machCode,
                                                 @ApiParam(name = "systemId", value = "账套Id", type = "String") @PathVariable("systemId") Long systemId,
                                                 @AuthenticationPrincipal Principal principal);

    @GetMapping("/prod-batch-last/{machCode}/{systemId}/{cart}")
    @ApiOperation(value = "车间现场/获取最后一个小车生产批", notes = "车间现场/获取最后一个小车生产批", tags = "车间现场")
    ResponseEntity<ObjectResult> getLastOneBatchByCart(@ApiParam(name = "machCode", value = "机台代码", type = "String") @PathVariable("machCode") String machCode,
                                                 @ApiParam(name = "systemId", value = "账套Id", type = "String") @PathVariable("systemId") Long systemId,
                                                 @ApiParam(name = "cart", value = "小车", type = "String") @PathVariable("cart") Boolean cart,
                                                 @AuthenticationPrincipal Principal principal);


    @GetMapping("/prod-batch/statistics-consume")
    @ApiOperation(value = "车间现场/根据批次获取物料消耗统计信息", notes = "车间现场/根据批次获取物料消耗统计信息", tags = "车间现场")
    ResponseEntity<ObjectResult> getMatStatisticsConsumeByProdBatch(@RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime);

    @GetMapping("/prod-batch/list/{machCode}/{isFinished}/{pageIndex}/{pageSize}")
    @ApiOperation(value = "车间现场/根据机台获取批次", notes = "车间现场/根据机台获取批次", tags = "车间现场")
    ResponseEntity<ListResult> getProdBatchByMachCode(@PathVariable("machCode") String machCode, @PathVariable("isFinished") Integer isFinished, @PathVariable("pageIndex") Long pageIndex, @PathVariable("pageSize") Long pageSize);


}
